<?php 
	/**
	 * 提现已发放记录
	 */
    session_start();
    require_once("../includes/public.inc.php");
    $openid = isset($_SESSION['openid'])?$_SESSION['openid']:'';
    $openusers =  mysql_fetch_array(mysql_query("select * from ".DBQIAN."users where openid='".$openid."' order by id desc limit 1"));
	//print_r($openusers);exit;
    if ($openusers) 
    {
        $buy = mysql_query("select * from ".DBQIAN."buylog where openid='".$openid."' order by create_time");  
		$buy_log = array();
		$totalmoney = 0.00;
        while ($row = mysql_fetch_array($buy))
		{
			$buy_log[] = $row;
			if ($row['paystatus'] == 1)
			{
				$totalmoney += $row['price'];
			}
		}
		$buy_wait = mysql_fetch_array(mysql_query("select count(*) as quantity from ".DBQIAN."buylog where status=2 and openid='".$openid."' order by create_time limit 1"));  
    }
    else
    {
       echo "<script>alert('非法进入!');history.back();</script>";
       exit;
    }
?>
<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,user-scalable=no,maximum-scale=1,initial-scale=1">
<title>购买记录</title>
<link type="text/css" href="css/css.css" rel="stylesheet" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<ul class="top-tool" style="top:0px; left:0px">
    <span class="back"><a href="javascript:history.go(-1)"><img src="./image/back_icon.png"></a></span>
    <span class="title">个人中心</span>
</ul>
<div style="height:50px"></div>
<div id="xq" class="pz-panel">
	<ul class="navs">
    <li><img src="<?=$openusers['headimg_url']?>" alt="头像"><p><?=$openusers['name']?></p></li>
    <li class="center"><img src="./image/ymai.png"><p>已购买：<?=$totalmoney?></p></li>
    <li><img src="./image/wff.png"><p>待发货：<?=$buy_wait['quantity'] ?></p></li>
	</ul>
</div>
<div id="xq" class="pz-panel">
<section id="cd-timeline" class="cd-container">
    <!--此处代码有数据时遍历用-->
    <? foreach ($buy_log as $bl):?>
        <div class="cd-timeline-block">
            <div class="cd-timeline-img cd-movie">
                <img src="./image/buy.png" /> 
            </div>
            <div class="cd-timeline-content">
            	<a href="orderdetail.php?id=<?=$bl['id']?>">
                <h4>产品：<?=$bl['product_name']?></h4>
                <p>下单时间：<?=$bl['create_time']?></p>
                <p>订单转态：
                	<?
						switch ($bl['status'])
						{
							case 1: echo "等待买家付款";break;
							case 2: echo "等待店铺发货";break;
							case 3: echo "等待买家付款";break;
							case 4: echo "等待买家收货";break;
							case 5: echo "等待店铺发货";break;
							case 6: echo "交易完成";break;
							case 7: echo "订单已关闭";break;
							case 8: echo "订单被卖家关闭";break;
						}
					?>
                </p>
                </a>
            </div>
        </div>
     <?endforeach;?> 
</section>
</div>
<div class="footer-tool">
	<div style="padding:0px;position:relative;margin:8px 6px;">
        <ul class="nav">
        	<li onClick="location.href='hblog.php'"><img src="./image/hb_icon.png"><p>红包</p></li>
		    <li onClick="location.href='cashlog.php'"><img src="./image/tx_icon.png"><p>提现</p></li>
		    <li onClick="location.href='productshow.php'"><img src="./image/cp_icon.png"><p>产品</p></li>
		    <li style="border-right:none" onClick="location.href='person.php'">
		       <img src="./image/gr_icon.png">
		       <p>我的</p>
		    </li>
        </ul>
	    <div style="clear:left">
	    </div>
	</div>
</div>
</body>
</html>
